import {onBeforeMount, onBeforeUnmount, onMounted, reactive} from "vue";

//默认暴露
export default function (){

    let point = reactive({
        x:0,
        y:0
    })
    //通过组合式api的形式使用声明周期钩子
    //beforeCreate 和created 被setup取代
    onBeforeMount(()=>{
        console.log('----onBeforeMount----')

    })
    function savePoint(e){
        point.x = e.pageX
        point.y = e.pageY
    }

    onMounted(()=>{
        console.log('----onMounted----')
        window.addEventListener('click',savePoint)
    })

    onBeforeUnmount(()=>{
        console.log('----onBeforeUnmount----')
        window.removeEventListener('click',savePoint)
    })

    return point


}



